﻿package com.designoutput.icon 
{
    import flash.display.*;
    import flash.geom.*;

    public class UI extends Object
    {

        public function UI()
        {
        }

        public static function Desaturate(param1:BitmapData) : void
        {
            var _RGB :uint = 0;
            var _r:int = 0;
            var _g:int = 0;
            var _b:int = 0;
            var hi:int = 0;
            var wi:int = 0;
            while (wi < param1.width)
            {
                hi = 0;
                while (hi < param1.height)
                {
                    
					_RGB = param1.getPixel(wi, hi);
					_r = _RGB >>> 16 & 255;
					_g = _RGB >>> 8 & 255;
					_b = _RGB & 255;
                    var t:* = 0.299 * _r + 0.587 * _g + 0.114 * _b;
					_g = t;
					_r = t;
                    param1.setPixel(wi, hi, _r << 16 | _g << 8 | _b);
					hi++;
                }
				wi++;
            }
        }

        public static function GetPart(sourceBmpd:BitmapData, x:int, y:int, w:int, h:int) : BitmapData
        {
            var _bmpd:* = new BitmapData(w, h);
			_bmpd.copyPixels(sourceBmpd, new Rectangle(x, y, w, h), sourceBmpd.rect.topLeft);
            return _bmpd;
        }

    }
}
